<#assign base=request.contextPath>
<!DOCTYPE html> 
<html>
	<head>
		<title></title>
		<meta charset="utf-8">
		<#include "common/reference.ftl" />
		<#include "common/ligerui.ftl" />
		<script type="text/javascript">
		<!--
			var ligerTable = null;
			$(function(){
				
				ligerTable = $('#table').ligerGrid({
					width:'98%',
					enabledSort:false,
					pageSizeOptions:[5,10,20,50,100,200],
					height:'auto',
					alternatingRow:true,
					url:'${base}/${route}/getList',
					parms:[{name:'dictId',value:'${dictId}'}],
					delayLoad:false,
					columns:[
						{display:'数据ID',name:'dataId',id:'dataId',align:'center'},
						{
							display:'所属字典名称',
							name:'dictName',
							id:'dictName',
							align:'center',
							render:function(row){
								if(row.dict != null && row.dict.dictName != null){
									return row.dict.dictName;
								}
								return '-';
							}
						},
						{display:'数据名称',name:'dataName',id:'dataName',align:'center'},
						{display:'数据值',name:'dataValue',id:'dataValue',align:'center'},
						{
							display:'是否启用',
							name:'enabled',
							id:'enabled',
							align:'center',
							render:function(row){
								var enabled = row.enabled;
						 		if(enabled){
						 			return '是';
						 		}
						 		return '否';
							}
						},
						{
							display:'操 作',
							align:'center',
							render:function(row){
								var dataId = row.dataId;
								return [ 
								'<a class="edit" href="javascript:void(0)" onclick="editItem('+dataId+')"  title="编辑">',
					                '<i class="fa fa-edit"></i>',
					            '</a>',
								'<a class="edit" href="javascript:void(0)" onclick="removeItem('+dataId+')"  title="删除">',
					                '<i class="fa fa-remove"></i>',
					            '</a>'
					            ].join('');
								
							}
						}
					]
				});
				
				$('#selDict').on('change', function(){
					reload();
				});
				
				function reload(){
					if(ligerTable){
						var dictId = $('#selDict').val();
						var dataName = $('#txtDataName').val();
						ligerTable.setParm('dictId',dictId);
						ligerTable.setParm('dataName',dataName);
						ligerTable.reload();
					}
				}
				
				$('#btnSearch').click(function(){
					reload();
				});
			});

		    function editItem(dataId){
	        	var url='${base}/${route}/edit/'+dataId+'?dictId=${dictId}';
	            changePage(url);
		    }
		    function removeItem(dataId){
		    	layer.confirm('确定要删除吗？',function(){
	    			$.ajax({
	            		url:'${base}/${route}/remove/'+dataId,
	            		type:'POST',
	            		data:{},
	            		dataType:'json',
	            		success:function(rst){
	            			layer.msg(rst.message);
	            			if(rst.status=='OK' && ligerTable != null ){
	            				ligerTable.reload();
	            			}
	            		}
	            	});	
	    		});
		    }
		//-->
		</script>
	</head>
	<body class="$configs["skinName"]">
		<#include "common/breadcrumb.ftl">
		<div class="widget-box">
			<div class="widget-header">
				<h5 class="lighter">数据字典数据查询</h5>
			</div>
			<div class="widget-body">
				<div class="widget-main">
					<div class="row">
						<div class="col-sm-5">
							<select id="selDict">
								<option value="0">全部</option>
							<#list dictList as item>
								<option value="${item.dictId}" >${item.dictName}</option>
							</#list>
							</select>
						</div>
						<div class="col-sm-5">
							<div class="input-group">
								<input id="txtDataName" type="text" class="form-control search-query" placeholder="请输入数据名称" />
								<span class="input-group-btn">
									<button id="btnSearch" type="button" class="btn btn-primary btn-sm">
										查询
										<i class="icon-search icon-on-right bigger-110"></i>
									</button>
								</span>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="widget-box">
			<div class="widget-header">
				<h5 class="lighter">
					<i class="icon-table"></i>
					数据字典数据列表
				</h5>
			</div>
			<div class="widget-body">
				<div id="table"><div>
			</div>
		</div>
	</body>
</html>